/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author freis
 */
@Entity
@Table(name = "recursos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Recursos.findAll", query = "SELECT r FROM Recursos r"),
    @NamedQuery(name = "Recursos.findByIdRecursos", query = "SELECT r FROM Recursos r WHERE r.idRecursos = :idRecursos"),
    @NamedQuery(name = "Recursos.findByNome", query = "SELECT r FROM Recursos r WHERE r.nome = :nome")})
public class Recursos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idRecursos")
    private Integer idRecursos;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nome")
    private String nome;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "recursos")
    private Collection<RecursosHasAccoes> recursosHasAccoesCollection;

    public Recursos() {
    }

    public Recursos(Integer idRecursos) {
        this.idRecursos = idRecursos;
    }

    public Recursos(Integer idRecursos, String nome) {
        this.idRecursos = idRecursos;
        this.nome = nome;
    }

    public Integer getIdRecursos() {
        return idRecursos;
    }

    public void setIdRecursos(Integer idRecursos) {
        this.idRecursos = idRecursos;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    @XmlTransient
    public Collection<RecursosHasAccoes> getRecursosHasAccoesCollection() {
        return recursosHasAccoesCollection;
    }

    public void setRecursosHasAccoesCollection(Collection<RecursosHasAccoes> recursosHasAccoesCollection) {
        this.recursosHasAccoesCollection = recursosHasAccoesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRecursos != null ? idRecursos.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Recursos)) {
            return false;
        }
        Recursos other = (Recursos) object;
        if ((this.idRecursos == null && other.idRecursos != null) || (this.idRecursos != null && !this.idRecursos.equals(other.idRecursos))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Recursos[ idRecursos=" + idRecursos + " ]";
    }
    
}
